let jdenticon = require("jdenticon");
let fs = require('fs');
let path = require('path');

let iconMaker = {
    generate: function (openid) {
        let buffer = jdenticon.toPng(openid, 200);
        let fileName = path.join(__dirname, '../www/static/lottery/images/avatars', openid + '.png');
        fs.writeFileSync(fileName, buffer);

        return openid + '.png';
    }
};

module.exports = iconMaker;
